# -*- coding: UTF-8 -*-
import mysql.connector

# 打开数据库连接
db = mysql.connector.connect(
    host="192.168.10.100",
    user="root",
    passwd="970226",  # 写上你的数据库密码
    database='demo_test'
)
# 获取操作游标
cursor = db.cursor()
# 执行SQL语句
cursor.execute("SELECT VERSION()")
# 获取一条数据
data = cursor.fetchone()
print("MySQL版本: %s " % data)

sql = 'select * from heros_temp'
cursor.execute(sql)
result = cursor.fetchall()
for i, item in result:
    print(i, item)

# 关闭游标&数据库连接
cursor.close()
db.close()
